namespace QMVnSoft.Invoices
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.Controls.ChildGridControls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormCTTPEditor : FormEditor
    {
        private IContainer components;
        private GridDetail grdDetail;
        private LabelControl lblDesc_EN;
        private LabelControl lblDien_Giai;
        private LabelControl lblGhi_Chu;
        private LabelControl lblMa_Bp;
        private LabelControl lblMa_Hd;
        private LabelControl lblMa_NN;
        private LabelControl lblMa_YC;
        private LabelControl lblTTien_Nt;
        private CTTPDataAccess oMethod;
        private TextControl txtDesc_EN;
        private TextControl txtDien_Giai;
        private TextControl txtGhi_Chu;
        private TextSearch txtMa_Bp;
        private TextSearch txtMa_Hd;
        private TextSearch txtMa_NN;
        private TextSearch txtMa_YC;
        private TextControl txtTen_Bp;
        private TextControl txtTen_Hd;
        private TextControl txtTen_NN;
        private TextControl txtTen_YC;
        private SearchColumn Column9;
        private DataGridViewTextBoxColumn Column10;
        private OptionColumn Column11;
        private SearchColumn Column16;
        private SearchColumn Column12;
        private SearchColumn Column13;
        private SearchColumn Column14;
        private SearchColumn Column17;
        private DateColumn Column18;
        private NumericColumn Column19;
        private NumericColumn Column20;
        private NumericColumn Column21;
        private NumericColumn Column22;
        private NumericColumn Column23;
        private NumericColumn Column24;
        private TextNumeric txtTTien_Nt;

        public FormCTTPEditor()
        {
            this.oMethod = new CTTPDataAccess();
            this.InitializeComponent();
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            base.ResizeForm();
        }

        public FormCTTPEditor(AppInvoiceLib po_AppInvoiceLib) : base(po_AppInvoiceLib)
        {
            this.oMethod = new CTTPDataAccess();
            this.InitializeComponent();
            base.InvoiceCode = po_AppInvoiceLib.InvoiceCode;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            this.SetFunctions();
            base.ResizeForm();
        }

        public FormCTTPEditor(string ps_InvoiceCode, string ps_MasterInvoiceOrder) : base(ps_InvoiceCode, ps_MasterInvoiceOrder)
        {
            this.oMethod = new CTTPDataAccess();
            this.InitializeComponent();
            base.InvoiceCode = ps_InvoiceCode;
            base.DetailGridBrowser.CellEnter += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEnter);
            base.DetailGridBrowser.CellEndEdit += new DataGridViewCellEventHandler(this.DetailGridBrowser_CellEndEdit);
            this.SetFunctions();
            base.LocalMasterRow = this.oMethod.GetMasterDataRow(base.SavedMasterOrder);
            base.LocalDetailDataSet = this.oMethod.GetDetailDataSet(base.SavedMasterOrder);
            this.OnShow();
            base.ResizeForm();
        }

        private bool AddNewRow(bool pb_Inserted)
        {
            if ((base.DetailGridBrowser.CurrentRow == null) || (base.DetailGridBrowser.CurrentRow.DataBoundItem == null))
            {
                return false;
            }
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            if ((((decimal) row["So_Luong9"]) == 0M) && (((decimal) row["So_Luong"]) == 0M))
            {
                return false;
            }
            int num = 0;
            if (pb_Inserted)
            {
                num = (int) row["Stt_Nv"];
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if ((row2.RowState != DataRowState.Deleted) && (((int) row2["Stt_Nv"]) > num))
                    {
                        row2["Stt_Nv"] = ((int) row2["Stt_Nv"]) + 1;
                    }
                }
            }
            else
            {
                foreach (DataRow row3 in base.LocalDetailTable.Rows)
                {
                    if ((row3.RowState != DataRowState.Deleted) && (((int) row3["Stt_Nv"]) > num))
                    {
                        num = (int) row3["Stt_Nv"];
                    }
                }
                if (((int) row["Stt_Nv"]) < num)
                {
                    return false;
                }
            }
            object obj2 = string.IsNullOrEmpty(this.txtMa_Bp.Text) ? row["Ma_Bp"] : this.txtMa_Bp.Value;
            object obj3 = string.IsNullOrEmpty(this.txtMa_Hd.Text) ? row["Ma_Hd"] : this.txtMa_Hd.Value;
            object obj4 = row["Ma_Yt"];
            object obj5 = row["Ma_Sp"];
            base.DetailGridBrowser.EndEdit();
            DataRow row4 = base.MakeDetailRow();
            int key = num + 1;
            row4["Stt_Nv"] = key;
            row4["He_So9"] = 1;
            row4["Ma_Bp"] = obj2;
            row4["Ma_Hd"] = obj3;
            row4["Ma_Yt"] = obj4;
            row4["Ma_Sp"] = obj5;
            row4["So_Luong9"] = 0;
            row4["Gia9"] = 0;
            row4["So_Luong"] = 0;
            row4["Gia"] = 0;
            row4["Tien"] = 0;
            row4["H_Luong"] = 0;
            row4["Do_Am_PT"] = 0;
            row4["Do_Con_PT"] = 0;
            base.LocalDetailTable.Rows.Add(row4);
            BindingSource dataSource = base.DetailGridBrowser.DataSource as BindingSource;
            dataSource.Position = dataSource.Find(base.DetailOrderString, key);
            return true;
        }

        private void Calculate(int pi_Position)
        {
            DataRow row = ((DataRowView) this.grdDetail.CurrentRow.DataBoundItem).Row;
            this.Calculate(row, pi_Position);
        }

        private void Calculate(DataRow po_Row, int pi_Position)
        {
            if ((pi_Position == 1) && (((decimal) po_Row["So_Luong9"]) != 0M))
            {
                po_Row["So_Luong"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["He_So9"]), base.QuantityDecimals);
                po_Row["Tien"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia9"]), base.LCAmountDecimals);
                po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
            }
            else if ((pi_Position == 2) && (((decimal) po_Row["So_Luong9"]) != 0M))
            {
                po_Row["Tien"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia9"]), base.LCAmountDecimals);
                po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
            }
            else if ((pi_Position == 3) && (((decimal) po_Row["So_Luong9"]) != 0M))
            {
                if (((decimal) po_Row["Tien"]) == 0M)
                {
                    po_Row["Tien"] = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia9"]), base.LCAmountDecimals);
                    po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
                }
                else if (((decimal) po_Row["Gia9"]) == 0M)
                {
                    po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong9"]), base.LCPriceDecimals);
                    po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
                }
                else
                {
                    decimal num = decimal.Round(((decimal) po_Row["So_Luong9"]) * ((decimal) po_Row["Gia9"]), base.FCAmountDecimals);
                    if ((((decimal) po_Row["Tien"]) < (num - base.DiffAmountRange)) || (((decimal) po_Row["Tien"]) > (num + base.DiffAmountRange)))
                    {
                        po_Row["Tien"] = num;
                        po_Row["Gia9"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong9"]), base.LCPriceDecimals);
                        po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
                    }
                    else
                    {
                        po_Row["Gia"] = decimal.Round(((decimal) po_Row["Tien"]) / ((decimal) po_Row["So_Luong"]), base.LCPriceDecimals);
                    }
                }
            }
            po_Row.EndEdit();
        }

        private void ChooseCommand(object sender, EventArgs e)
        {
            if (base.txtNgay_Ct.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_YC.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã yêu cầu!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else if (this.txtMa_NN.Value.Equals(DBNull.Value))
            {
                MessageBox.Show("Chưa nhập mã người nhận!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            else
            {
                DataRow row;
                DataTable table = new DataTable();
                DataColumn column = new DataColumn("Stt0_D", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Bp", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Hd", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ma_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Ten_Vt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("Dvt", typeof(string));
                table.Columns.Add(column);
                column = new DataColumn("He_So9", typeof(decimal));
                table.Columns.Add(column);
                column = new DataColumn("So_Luong", typeof(decimal));
                table.Columns.Add(column);
                table.PrimaryKey = new DataColumn[] { table.Columns["Stt0_D"] };
                foreach (DataRow row2 in base.LocalDetailTable.Rows)
                {
                    if (((row2.RowState != DataRowState.Deleted) && !string.IsNullOrEmpty(row2["Ma_Vt"].ToString())) && (!string.IsNullOrEmpty(row2["Stt0_D"].ToString()) && (table.Rows.Find(row2["Stt0_D"]) == null)))
                    {
                        row = table.NewRow();
                        row["Stt0_D"] = row2["Stt0_D"];
                        row["Ma_Bp"] = row2["Ma_Bp"];
                        row["Ma_Hd"] = row2["Ma_Hd"];
                        row["Ma_Vt"] = row2["Ma_Vt"];
                        row["Ten_Vt"] = row2["Ten_Vt"];
                        row["Dvt"] = row2["Dvt"];
                        row["He_So9"] = row2["He_So9"];
                        row["So_Luong"] = row2["So_Luong"];
                        table.Rows.Add(row);
                    }
                }
                FormCTSX2F4Editor editor = new FormCTSX2F4Editor(base.SavedMasterOrder, base.txtNgay_Ct.Value, table);
                editor.ShowDialog();
                if (editor.CheckAccepted)
                {
                    int num = 0;
                    object obj2 = "";
                    object obj3 = "";
                    object obj4 = 0;
                    object obj5 = 0;
                    base.LocalDetailTable.AcceptChanges();
                    foreach (DataRow row3 in base.LocalDetailTable.Rows)
                    {
                        if (row3.RowState != DataRowState.Deleted)
                        {
                            row3.Delete();
                        }
                    }
                    foreach (DataRow row4 in table.Rows)
                    {
                        if (((row4.RowState != DataRowState.Deleted) && !row4["So_Luong"].Equals(DBNull.Value)) && !(((decimal) row4["So_Luong"]) == 0M))
                        {
                            num++;
                            row = base.MakeDetailRow();
                            obj2 = string.IsNullOrEmpty(row4["Ma_Bp"].ToString()) ? this.txtMa_Bp.Value : row4["Ma_Bp"];
                            obj3 = string.IsNullOrEmpty(row4["Ma_Hd"].ToString()) ? this.txtMa_Hd.Value : row4["Ma_Hd"];
                            obj5 = row4["So_Luong"];
                            obj4 = decimal.Round(((decimal) obj5) / ((decimal) row4["He_So9"]), base.QuantityDecimals);
                            row["Stt0_D"] = row4["Stt0_D"];
                            row["Stt_Nv"] = num;
                            row["Ma_Vt"] = row4["Ma_Vt"];
                            row["Ten_Vt"] = row4["Ten_Vt"];
                            row["Dvt"] = row4["Dvt"];
                            row["He_So9"] = row4["He_So9"];
                            row["Ma_Bp"] = obj2;
                            row["Ma_Hd"] = obj3;
                            row["So_Luong9"] = obj4;
                            row["So_Luong"] = obj5;
                            row["Gia9"] = 0;
                            row["Gia"] = 0;
                            row["Tien"] = 0;
                            row["H_Luong"] = 0;
                            row["Do_Am_PT"] = 0;
                            row["Do_Con_PT"] = 0;
                            base.LocalDetailTable.Rows.Add(row);
                        }
                    }
                    base.DetailGridBrowser.CurrentCell = base.DetailGridBrowser.FirstDisplayedCell;
                    base.DetailGridBrowser.Focus();
                }
            }
        }

        private void DetailGridBrowser_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                this.SetItemRatio();
            }
            else if (e.ColumnIndex == 2)
            {
                this.SetItemRatio();
            }
            else if (e.ColumnIndex == 12)
            {
                this.Calculate(1);
                this.Sum();
            }
            else if (e.ColumnIndex == 13)
            {
                this.Calculate(2);
                this.Sum();
            }
            else if (e.ColumnIndex == 14)
            {
                this.Calculate(3);
                this.Sum();
            }
        }

        private void DetailGridBrowser_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                this.SetItemUnits();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void grdDetail_CellBottomLeftLeaved(object sender, EventArgs e)
        {
            if (((base.DetailGridBrowser.Rows.Count == 1) || !string.IsNullOrEmpty(((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row["Ma_Vt"].ToString())) || !string.IsNullOrEmpty(base.ActiveControl.Text))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.NextCell;
            }
            else
            {
                this.txtGhi_Chu.Focus();
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.DeleteCurrentRow;
            }
        }

        private void grdDetail_CellRightLeaved(object sender, EventArgs e)
        {
            if (this.AddNewRow(false))
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCell;
            }
            else
            {
                (base.DetailGridBrowser as GridDetail).UserMoveNextCell = GridDetail.MoveNextType.FirstCellNextRow;
            }
        }

        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormCTTPEditor));
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle();
            this.txtDesc_EN = new QMVnSoft.Controls.TextControl();
            this.txtDien_Giai = new QMVnSoft.Controls.TextControl();
            this.txtTen_Hd = new QMVnSoft.Controls.TextControl();
            this.txtTen_Bp = new QMVnSoft.Controls.TextControl();
            this.lblDesc_EN = new QMVnSoft.Controls.LabelControl();
            this.lblDien_Giai = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Hd = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Hd = new QMVnSoft.Controls.LabelControl();
            this.txtMa_Bp = new QMVnSoft.Controls.TextSearch();
            this.lblMa_Bp = new QMVnSoft.Controls.LabelControl();
            this.txtTTien_Nt = new QMVnSoft.Controls.TextNumeric();
            this.lblTTien_Nt = new QMVnSoft.Controls.LabelControl();
            this.lblGhi_Chu = new QMVnSoft.Controls.LabelControl();
            this.grdDetail = new QMVnSoft.Controls.GridDetail();
            this.txtGhi_Chu = new QMVnSoft.Controls.TextControl();
            this.txtTen_NN = new QMVnSoft.Controls.TextControl();
            this.txtTen_YC = new QMVnSoft.Controls.TextControl();
            this.txtMa_NN = new QMVnSoft.Controls.TextSearch();
            this.txtMa_YC = new QMVnSoft.Controls.TextSearch();
            this.lblMa_NN = new QMVnSoft.Controls.LabelControl();
            this.lblMa_YC = new QMVnSoft.Controls.LabelControl();
            this.Column9 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column11 = new QMVnSoft.Controls.ChildGridControls.OptionColumn();
            this.Column16 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column12 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column13 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column14 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column17 = new QMVnSoft.Controls.ChildGridControls.SearchColumn();
            this.Column18 = new QMVnSoft.Controls.ChildGridControls.DateColumn();
            this.Column19 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column20 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column21 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column22 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column23 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            this.Column24 = new QMVnSoft.Controls.ChildGridControls.NumericColumn();
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).BeginInit();
            this.SuspendLayout();
            // 
            // lblPhan_Loai
            // 
            this.lblPhan_Loai.Location = new System.Drawing.Point(12, 493);
            // 
            // txtMa_Loai1
            // 
            this.txtMa_Loai1.Location = new System.Drawing.Point(99, 490);
            this.txtMa_Loai1.TabIndex = 13;
            // 
            // txtMa_Loai2
            // 
            this.txtMa_Loai2.Location = new System.Drawing.Point(327, 490);
            this.txtMa_Loai2.TabIndex = 14;
            // 
            // txtMa_Loai3
            // 
            this.txtMa_Loai3.Location = new System.Drawing.Point(555, 490);
            this.txtMa_Loai3.TabIndex = 15;
            // 
            // txtNgay_Ct
            // 
            this.txtNgay_Ct.TabIndex = 1;
            // 
            // txtNgay_Ps
            // 
            this.txtNgay_Ps.TabIndex = 0;
            // 
            // txtSo_Ct
            // 
            this.txtSo_Ct.TabIndex = 2;
            // 
            // txtDesc_EN
            // 
            this.txtDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.txtDesc_EN.CheckTextSearched = false;
            this.txtDesc_EN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDesc_EN.Location = new System.Drawing.Point(487, 158);
            this.txtDesc_EN.MaxLength = 254;
            this.txtDesc_EN.Name = "txtDesc_EN";
            this.txtDesc_EN.OldValue = null;
            this.txtDesc_EN.Size = new System.Drawing.Size(295, 20);
            this.txtDesc_EN.TabIndex = 10;
            this.txtDesc_EN.UserTextLength = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDesc_EN.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDesc_EN.Value = ((object)(resources.GetObject("txtDesc_EN.Value")));
            // 
            // txtDien_Giai
            // 
            this.txtDien_Giai.CheckTextSearched = false;
            this.txtDien_Giai.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtDien_Giai.Location = new System.Drawing.Point(99, 158);
            this.txtDien_Giai.MaxLength = 254;
            this.txtDien_Giai.Name = "txtDien_Giai";
            this.txtDien_Giai.OldValue = null;
            this.txtDien_Giai.Size = new System.Drawing.Size(296, 20);
            this.txtDien_Giai.TabIndex = 9;
            this.txtDien_Giai.UserTextLength = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtDien_Giai.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtDien_Giai.Value = ((object)(resources.GetObject("txtDien_Giai.Value")));
            // 
            // txtTen_Hd
            // 
            this.txtTen_Hd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Hd.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Hd.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Hd.CheckTextSearched = false;
            this.txtTen_Hd.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Enabled = false;
            this.txtTen_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Hd.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Hd.Location = new System.Drawing.Point(223, 140);
            this.txtTen_Hd.Name = "txtTen_Hd";
            this.txtTen_Hd.OldValue = null;
            this.txtTen_Hd.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Hd.TabIndex = 86;
            this.txtTen_Hd.UserTextLength = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Hd.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Hd.Value = ((object)(resources.GetObject("txtTen_Hd.Value")));
            // 
            // txtTen_Bp
            // 
            this.txtTen_Bp.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_Bp.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_Bp.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_Bp.CheckTextSearched = false;
            this.txtTen_Bp.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Enabled = false;
            this.txtTen_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_Bp.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_Bp.Location = new System.Drawing.Point(223, 119);
            this.txtTen_Bp.Name = "txtTen_Bp";
            this.txtTen_Bp.OldValue = null;
            this.txtTen_Bp.Size = new System.Drawing.Size(559, 13);
            this.txtTen_Bp.TabIndex = 87;
            this.txtTen_Bp.UserTextLength = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_Bp.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_Bp.Value = ((object)(resources.GetObject("txtTen_Bp.Value")));
            // 
            // lblDesc_EN
            // 
            this.lblDesc_EN.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
            this.lblDesc_EN.AutoSize = true;
            this.lblDesc_EN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDesc_EN.Location = new System.Drawing.Point(410, 161);
            this.lblDesc_EN.Name = "lblDesc_EN";
            this.lblDesc_EN.Size = new System.Drawing.Size(71, 14);
            this.lblDesc_EN.TabIndex = 80;
            this.lblDesc_EN.Text = "Diễn giải (EN)";
            // 
            // lblDien_Giai
            // 
            this.lblDien_Giai.AutoSize = true;
            this.lblDien_Giai.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblDien_Giai.Location = new System.Drawing.Point(12, 161);
            this.lblDien_Giai.Name = "lblDien_Giai";
            this.lblDien_Giai.Size = new System.Drawing.Size(73, 14);
            this.lblDien_Giai.TabIndex = 81;
            this.lblDien_Giai.Text = "Diễn giải (VN)";
            // 
            // txtMa_Hd
            // 
            this.txtMa_Hd.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Hd.CheckTextSearched = false;
            this.txtMa_Hd.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Hd.EmptyIsValid = true;
            this.txtMa_Hd.FieldDisplay = "Ten_Hd";
            this.txtMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Hd.FoundIsValid = true;
            this.txtMa_Hd.Location = new System.Drawing.Point(99, 137);
            this.txtMa_Hd.MaxLength = 32;
            this.txtMa_Hd.Name = "txtMa_Hd";
            this.txtMa_Hd.OldValue = null;
            this.txtMa_Hd.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Hd.TabIndex = 8;
            this.txtMa_Hd.TableName = "DMHD";
            this.txtMa_Hd.TextDisplay = this.txtTen_Hd;
            this.txtMa_Hd.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Hd.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Hd.Value = ((object)(resources.GetObject("txtMa_Hd.Value")));
            this.txtMa_Hd.Validated += new System.EventHandler(this.txtMa_Hd_Validated);
            // 
            // lblMa_Hd
            // 
            this.lblMa_Hd.AutoSize = true;
            this.lblMa_Hd.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Hd.Location = new System.Drawing.Point(12, 140);
            this.lblMa_Hd.Name = "lblMa_Hd";
            this.lblMa_Hd.Size = new System.Drawing.Size(54, 14);
            this.lblMa_Hd.TabIndex = 82;
            this.lblMa_Hd.Text = "Hợp đồng";
            // 
            // txtMa_Bp
            // 
            this.txtMa_Bp.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_Bp.CheckTextSearched = false;
            this.txtMa_Bp.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_Bp.EmptyIsValid = true;
            this.txtMa_Bp.FieldDisplay = "Ten_Bp";
            this.txtMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_Bp.FoundIsValid = true;
            this.txtMa_Bp.Location = new System.Drawing.Point(99, 116);
            this.txtMa_Bp.MaxLength = 32;
            this.txtMa_Bp.Name = "txtMa_Bp";
            this.txtMa_Bp.OldValue = null;
            this.txtMa_Bp.Size = new System.Drawing.Size(118, 20);
            this.txtMa_Bp.TabIndex = 7;
            this.txtMa_Bp.TableName = "DMBP";
            this.txtMa_Bp.TextDisplay = this.txtTen_Bp;
            this.txtMa_Bp.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_Bp.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_Bp.Value = ((object)(resources.GetObject("txtMa_Bp.Value")));
            this.txtMa_Bp.Validated += new System.EventHandler(this.txtMa_Bp_Validated);
            // 
            // lblMa_Bp
            // 
            this.lblMa_Bp.AutoSize = true;
            this.lblMa_Bp.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_Bp.Location = new System.Drawing.Point(12, 119);
            this.lblMa_Bp.Name = "lblMa_Bp";
            this.lblMa_Bp.Size = new System.Drawing.Size(47, 14);
            this.lblMa_Bp.TabIndex = 83;
            this.lblMa_Bp.Text = "Bộ phận";
            // 
            // txtTTien_Nt
            // 
            this.txtTTien_Nt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTTien_Nt.BackColor = System.Drawing.Color.White;
            this.txtTTien_Nt.Enabled = false;
            this.txtTTien_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTTien_Nt.ForeColor = System.Drawing.Color.Black;
            this.txtTTien_Nt.Location = new System.Drawing.Point(674, 468);
            this.txtTTien_Nt.Name = "txtTTien_Nt";
            this.txtTTien_Nt.NumericValue = new decimal(new int[] {
            0,
            0,
            0,
            0});
            this.txtTTien_Nt.OldValue = null;
            this.txtTTien_Nt.Size = new System.Drawing.Size(108, 20);
            this.txtTTien_Nt.TabIndex = 29;
            this.txtTTien_Nt.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
            this.txtTTien_Nt.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.LocalAmount;
            this.txtTTien_Nt.Value = ((object)(resources.GetObject("txtTTien_Nt.Value")));
            // 
            // lblTTien_Nt
            // 
            this.lblTTien_Nt.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.lblTTien_Nt.AutoSize = true;
            this.lblTTien_Nt.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblTTien_Nt.Location = new System.Drawing.Point(617, 471);
            this.lblTTien_Nt.Name = "lblTTien_Nt";
            this.lblTTien_Nt.Size = new System.Drawing.Size(51, 14);
            this.lblTTien_Nt.TabIndex = 101;
            this.lblTTien_Nt.Text = "Tổng tiền";
            // 
            // lblGhi_Chu
            // 
            this.lblGhi_Chu.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            this.lblGhi_Chu.AutoSize = true;
            this.lblGhi_Chu.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblGhi_Chu.Location = new System.Drawing.Point(12, 471);
            this.lblGhi_Chu.Name = "lblGhi_Chu";
            this.lblGhi_Chu.Size = new System.Drawing.Size(44, 14);
            this.lblGhi_Chu.TabIndex = 99;
            this.lblGhi_Chu.Text = "Ghi chú";
            // 
            // grdDetail
            // 
            this.grdDetail.AllowUserToAddRows = false;
            this.grdDetail.AllowUserToDeleteRows = false;
            this.grdDetail.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.grdDetail.CheckAutoSize = true;
            this.grdDetail.CheckColor = false;
            this.grdDetail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.grdDetail.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column9,
            this.Column10,
            this.Column11,
            this.Column16,
            this.Column12,
            this.Column13,
            this.Column14,
            this.Column17,
            this.Column18,
            this.Column19,
            this.Column20,
            this.Column21,
            this.Column22,
            this.Column23,
            this.Column24});
            this.grdDetail.Font = new System.Drawing.Font("Arial", 8.25F);
            this.grdDetail.Location = new System.Drawing.Point(0, 184);
            this.grdDetail.Name = "grdDetail";
            this.grdDetail.Size = new System.Drawing.Size(794, 278);
            this.grdDetail.TabIndex = 11;
            this.grdDetail.CellRightLeaved += new System.EventHandler(this.grdDetail_CellRightLeaved);
            this.grdDetail.CellBottomLeftLeaved += new System.EventHandler(this.grdDetail_CellBottomLeftLeaved);
            // 
            // txtGhi_Chu
            // 
            this.txtGhi_Chu.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtGhi_Chu.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtGhi_Chu.CheckTextSearched = false;
            this.txtGhi_Chu.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtGhi_Chu.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtGhi_Chu.Location = new System.Drawing.Point(99, 468);
            this.txtGhi_Chu.MaxLength = 254;
            this.txtGhi_Chu.Name = "txtGhi_Chu";
            this.txtGhi_Chu.OldValue = null;
            this.txtGhi_Chu.Size = new System.Drawing.Size(455, 20);
            this.txtGhi_Chu.TabIndex = 12;
            this.txtGhi_Chu.UserTextLength = QMVnSoft.AppInstance.TextControlLength.InvoiceDescription;
            this.txtGhi_Chu.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtGhi_Chu.Value = ((object)(resources.GetObject("txtGhi_Chu.Value")));
            // 
            // txtTen_NN
            // 
            this.txtTen_NN.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_NN.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_NN.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_NN.CheckTextSearched = false;
            this.txtTen_NN.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_NN.Enabled = false;
            this.txtTen_NN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_NN.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_NN.Location = new System.Drawing.Point(223, 98);
            this.txtTen_NN.Name = "txtTen_NN";
            this.txtTen_NN.OldValue = null;
            this.txtTen_NN.Size = new System.Drawing.Size(559, 13);
            this.txtTen_NN.TabIndex = 106;
            this.txtTen_NN.UserTextLength = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_NN.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_NN.Value = ((object)(resources.GetObject("txtTen_NN.Value")));
            // 
            // txtTen_YC
            // 
            this.txtTen_YC.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.txtTen_YC.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(194)))), ((int)(((byte)(217)))), ((int)(((byte)(247)))));
            this.txtTen_YC.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.txtTen_YC.CheckTextSearched = false;
            this.txtTen_YC.DisabledForeColor = System.Drawing.Color.Blue;
            this.txtTen_YC.Enabled = false;
            this.txtTen_YC.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtTen_YC.ForeColor = System.Drawing.Color.Blue;
            this.txtTen_YC.Location = new System.Drawing.Point(223, 77);
            this.txtTen_YC.Name = "txtTen_YC";
            this.txtTen_YC.OldValue = null;
            this.txtTen_YC.Size = new System.Drawing.Size(559, 13);
            this.txtTen_YC.TabIndex = 107;
            this.txtTen_YC.UserTextLength = QMVnSoft.AppInstance.TextControlLength.None;
            this.txtTen_YC.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.txtTen_YC.Value = ((object)(resources.GetObject("txtTen_YC.Value")));
            // 
            // txtMa_NN
            // 
            this.txtMa_NN.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_NN.CheckTextSearched = false;
            this.txtMa_NN.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_NN.FieldDisplay = "Ten_Dt";
            this.txtMa_NN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_NN.Location = new System.Drawing.Point(99, 95);
            this.txtMa_NN.MaxLength = 32;
            this.txtMa_NN.Name = "txtMa_NN";
            this.txtMa_NN.OldValue = null;
            this.txtMa_NN.Size = new System.Drawing.Size(118, 20);
            this.txtMa_NN.TabIndex = 6;
            this.txtMa_NN.TableName = "DMDT";
            this.txtMa_NN.TextDisplay = this.txtTen_NN;
            this.txtMa_NN.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_NN.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_NN.Value = ((object)(resources.GetObject("txtMa_NN.Value")));
            // 
            // txtMa_YC
            // 
            this.txtMa_YC.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
            this.txtMa_YC.CheckTextSearched = false;
            this.txtMa_YC.DisabledForeColor = System.Drawing.Color.Empty;
            this.txtMa_YC.FieldDisplay = "Ten_Dt";
            this.txtMa_YC.Font = new System.Drawing.Font("Arial", 8.25F);
            this.txtMa_YC.Location = new System.Drawing.Point(99, 74);
            this.txtMa_YC.MaxLength = 32;
            this.txtMa_YC.Name = "txtMa_YC";
            this.txtMa_YC.OldValue = null;
            this.txtMa_YC.Size = new System.Drawing.Size(118, 20);
            this.txtMa_YC.TabIndex = 5;
            this.txtMa_YC.TableName = "DMDT";
            this.txtMa_YC.TextDisplay = this.txtTen_YC;
            this.txtMa_YC.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.txtMa_YC.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.All;
            this.txtMa_YC.Value = ((object)(resources.GetObject("txtMa_YC.Value")));
            // 
            // lblMa_NN
            // 
            this.lblMa_NN.AutoSize = true;
            this.lblMa_NN.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_NN.Location = new System.Drawing.Point(12, 98);
            this.lblMa_NN.Name = "lblMa_NN";
            this.lblMa_NN.Size = new System.Drawing.Size(63, 14);
            this.lblMa_NN.TabIndex = 105;
            this.lblMa_NN.Text = "Người nhận";
            // 
            // lblMa_YC
            // 
            this.lblMa_YC.AutoSize = true;
            this.lblMa_YC.Font = new System.Drawing.Font("Arial", 8.25F);
            this.lblMa_YC.Location = new System.Drawing.Point(12, 77);
            this.lblMa_YC.Name = "lblMa_YC";
            this.lblMa_YC.Size = new System.Drawing.Size(78, 14);
            this.lblMa_YC.TabIndex = 104;
            this.lblMa_YC.Text = "Người yêu cầu";
            // 
            // Column9
            // 
            this.Column9.DataPropertyName = "Ma_Vt";
            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column9.DefaultCellStyle = dataGridViewCellStyle1;
            this.Column9.DestinationFields = "Ten_Vt, Dvt";
            this.Column9.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column9.EmptyIsValid = true;
            this.Column9.FirstFilter = "Loai_Vt = \'1\'";
            this.Column9.HeaderText = "Mã vật tư";
            this.Column9.MinimumWidth = 90;
            this.Column9.Name = "Column9";
            this.Column9.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column9.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column9.SourceFields = "Ten_Vt, Dvt";
            this.Column9.TableName = "DMVT";
            this.Column9.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column9.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column9.Width = 90;
            // 
            // Column10
            // 
            this.Column10.DataPropertyName = "Ten_Vt";
            this.Column10.HeaderText = "Tên vật tư";
            this.Column10.MinimumWidth = 120;
            this.Column10.Name = "Column10";
            this.Column10.ReadOnly = true;
            this.Column10.Width = 120;
            // 
            // Column11
            // 
            this.Column11.DataPropertyName = "Dvt";
            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column11.DefaultCellStyle = dataGridViewCellStyle2;
            this.Column11.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column11.HeaderText = "Đvt";
            this.Column11.MinimumWidth = 40;
            this.Column11.Name = "Column11";
            this.Column11.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column11.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column11.UserTextLength = QMVnSoft.AppInstance.TextControlLength.None;
            this.Column11.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column11.Width = 40;
            // 
            // Column16
            // 
            this.Column16.DataPropertyName = "Ma_Sp";
            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column16.DefaultCellStyle = dataGridViewCellStyle3;
            this.Column16.DestinationFields = "Ten_Sp";
            this.Column16.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column16.EmptyIsValid = true;
            this.Column16.HeaderText = "Sản phẩm";
            this.Column16.MinimumWidth = 70;
            this.Column16.Name = "Column16";
            this.Column16.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column16.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column16.SourceFields = "Ten_Sp";
            this.Column16.TableName = "DMSP";
            this.Column16.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column16.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column16.Width = 70;
            // 
            // Column12
            // 
            this.Column12.DataPropertyName = "Ma_Yt";
            dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column12.DefaultCellStyle = dataGridViewCellStyle4;
            this.Column12.DestinationFields = "Ten_Yt";
            this.Column12.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column12.HeaderText = "Yếu tố";
            this.Column12.Name = "Column12";
            this.Column12.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column12.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column12.SourceFields = "Ten_Yt";
            this.Column12.TableName = "DMYT";
            this.Column12.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column12.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column12.Width = 70;
            // 
            // Column13
            // 
            this.Column13.DataPropertyName = "Ma_Bp";
            dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column13.DefaultCellStyle = dataGridViewCellStyle5;
            this.Column13.DestinationFields = "Ten_Bp";
            this.Column13.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column13.EmptyIsValid = true;
            this.Column13.HeaderText = "Bộ phận";
            this.Column13.Name = "Column13";
            this.Column13.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column13.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column13.SourceFields = "Ten_Bp";
            this.Column13.TableName = "DMBP";
            this.Column13.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column13.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column13.Width = 70;
            // 
            // Column14
            // 
            this.Column14.DataPropertyName = "Ma_Hd";
            dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column14.DefaultCellStyle = dataGridViewCellStyle6;
            this.Column14.DestinationFields = "Ten_Hd";
            this.Column14.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column14.EmptyIsValid = true;
            this.Column14.HeaderText = "Hợp đồng";
            this.Column14.Name = "Column14";
            this.Column14.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column14.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column14.SourceFields = "Ten_Hd";
            this.Column14.TableName = "DMHD";
            this.Column14.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column14.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column14.Width = 70;
            // 
            // Column17
            // 
            this.Column17.DataPropertyName = "Lo_Hang";
            dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column17.DefaultCellStyle = dataGridViewCellStyle7;
            this.Column17.DisabledForeColor = System.Drawing.Color.Blue;
            this.Column17.EmptyIsValid = true;
            this.Column17.HeaderText = "Lô hàng";
            this.Column17.Name = "Column17";
            this.Column17.Resizable = System.Windows.Forms.DataGridViewTriState.True;
            this.Column17.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column17.TableName = "LOHANG";
            this.Column17.UserTextLength = QMVnSoft.AppInstance.TextControlLength.ItemCode;
            this.Column17.UserTrimMode = QMVnSoft.AppInstance.TextControlTrimMode.Right;
            this.Column17.Width = 70;
            // 
            // Column18
            // 
            this.Column18.DataPropertyName = "Han_Dung";
            dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
            this.Column18.DefaultCellStyle = dataGridViewCellStyle8;
            this.Column18.HeaderText = "Hạn dùng";
            this.Column18.Name = "Column18";
            this.Column18.Resizable = System.Windows.Forms.DataGridViewTriState.False;
            this.Column18.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column18.Width = 62;
            // 
            // Column19
            // 
            this.Column19.DataPropertyName = "H_Luong";
            dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column19.DefaultCellStyle = dataGridViewCellStyle9;
            this.Column19.HeaderText = "Hàm lượng";
            this.Column19.Name = "Column19";
            this.Column19.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column19.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.Percent;
            this.Column19.Width = 70;
            // 
            // Column20
            // 
            this.Column20.DataPropertyName = "Do_Am_PT";
            dataGridViewCellStyle10.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column20.DefaultCellStyle = dataGridViewCellStyle10;
            this.Column20.HeaderText = "Độ ẩm";
            this.Column20.Name = "Column20";
            this.Column20.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column20.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.Percent;
            this.Column20.Width = 70;
            // 
            // Column21
            // 
            this.Column21.DataPropertyName = "Do_Con_PT";
            dataGridViewCellStyle11.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column21.DefaultCellStyle = dataGridViewCellStyle11;
            this.Column21.HeaderText = "Độ cồn";
            this.Column21.Name = "Column21";
            this.Column21.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column21.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.Percent;
            this.Column21.Width = 70;
            // 
            // Column22
            // 
            this.Column22.DataPropertyName = "So_Luong9";
            dataGridViewCellStyle12.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column22.DefaultCellStyle = dataGridViewCellStyle12;
            this.Column22.HeaderText = "Số lượng";
            this.Column22.Name = "Column22";
            this.Column22.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column22.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.Quantity;
            this.Column22.Width = 70;
            this.Column22.ZeroIsValid = true;
            // 
            // Column23
            // 
            this.Column23.DataPropertyName = "Gia9";
            dataGridViewCellStyle13.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column23.DefaultCellStyle = dataGridViewCellStyle13;
            this.Column23.HeaderText = "Đơn giá";
            this.Column23.Name = "Column23";
            this.Column23.ReadOnly = true;
            this.Column23.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column23.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.ForeignPrice;
            this.Column23.Width = 70;
            this.Column23.ZeroIsValid = true;
            // 
            // Column24
            // 
            this.Column24.DataPropertyName = "Tien_Nt";
            dataGridViewCellStyle14.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleRight;
            this.Column24.DefaultCellStyle = dataGridViewCellStyle14;
            this.Column24.HeaderText = "Thành tiền";
            this.Column24.MinimumWidth = 90;
            this.Column24.Name = "Column24";
            this.Column24.ReadOnly = true;
            this.Column24.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
            this.Column24.UserTextNumericFormat = QMVnSoft.AppInstance.TextNumericFormat.ForeignAmount;
            this.Column24.Width = 90;
            this.Column24.ZeroIsValid = true;
            // 
            // FormCTTPEditor
            // 
            this.ClientSize = new System.Drawing.Size(794, 534);
            this.Controls.Add(this.txtTen_NN);
            this.Controls.Add(this.txtTen_YC);
            this.Controls.Add(this.txtMa_NN);
            this.Controls.Add(this.txtMa_YC);
            this.Controls.Add(this.lblMa_NN);
            this.Controls.Add(this.lblMa_YC);
            this.Controls.Add(this.txtTTien_Nt);
            this.Controls.Add(this.lblTTien_Nt);
            this.Controls.Add(this.lblGhi_Chu);
            this.Controls.Add(this.txtDesc_EN);
            this.Controls.Add(this.txtDien_Giai);
            this.Controls.Add(this.txtTen_Hd);
            this.Controls.Add(this.txtTen_Bp);
            this.Controls.Add(this.lblDesc_EN);
            this.Controls.Add(this.lblDien_Giai);
            this.Controls.Add(this.txtGhi_Chu);
            this.Controls.Add(this.txtMa_Hd);
            this.Controls.Add(this.lblMa_Hd);
            this.Controls.Add(this.txtMa_Bp);
            this.Controls.Add(this.lblMa_Bp);
            this.Controls.Add(this.grdDetail);
            this.Name = "FormCTTPEditor";
            this.Controls.SetChildIndex(this.grdDetail, 0);
            this.Controls.SetChildIndex(this.lblPhan_Loai, 0);
            this.Controls.SetChildIndex(this.txtSo_Ct, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ps, 0);
            this.Controls.SetChildIndex(this.txtNgay_Ct, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai1, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai2, 0);
            this.Controls.SetChildIndex(this.txtMa_Loai3, 0);
            this.Controls.SetChildIndex(this.lblMa_Bp, 0);
            this.Controls.SetChildIndex(this.txtMa_Bp, 0);
            this.Controls.SetChildIndex(this.lblMa_Hd, 0);
            this.Controls.SetChildIndex(this.txtMa_Hd, 0);
            this.Controls.SetChildIndex(this.txtGhi_Chu, 0);
            this.Controls.SetChildIndex(this.lblDien_Giai, 0);
            this.Controls.SetChildIndex(this.lblDesc_EN, 0);
            this.Controls.SetChildIndex(this.txtTen_Bp, 0);
            this.Controls.SetChildIndex(this.txtTen_Hd, 0);
            this.Controls.SetChildIndex(this.txtDien_Giai, 0);
            this.Controls.SetChildIndex(this.txtDesc_EN, 0);
            this.Controls.SetChildIndex(this.lblGhi_Chu, 0);
            this.Controls.SetChildIndex(this.lblTTien_Nt, 0);
            this.Controls.SetChildIndex(this.txtTTien_Nt, 0);
            this.Controls.SetChildIndex(this.lblMa_YC, 0);
            this.Controls.SetChildIndex(this.lblMa_NN, 0);
            this.Controls.SetChildIndex(this.txtMa_YC, 0);
            this.Controls.SetChildIndex(this.txtMa_NN, 0);
            this.Controls.SetChildIndex(this.txtTen_YC, 0);
            this.Controls.SetChildIndex(this.txtTen_NN, 0);
            ((System.ComponentModel.ISupportInitialize)(this.grdDetail)).EndInit();
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        internal override void OnAdd()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow = base.MakeMasterRow();
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.LocalMasterRow["TTien0"] = 0;
            base.MakeDetailTable();
            base.LocalDetailTable.Rows[0]["Stt_Nv"] = 1;
            base.LocalDetailTable.Rows[0]["He_So9"] = 1;
            base.LocalDetailTable.Rows[0]["So_Luong9"] = 0;
            base.LocalDetailTable.Rows[0]["Gia9"] = 0;
            base.LocalDetailTable.Rows[0]["So_Luong"] = 0;
            base.LocalDetailTable.Rows[0]["Gia"] = 0;
            base.LocalDetailTable.Rows[0]["Tien"] = 0;
            base.LocalDetailTable.Rows[0]["H_Luong"] = 0;
            base.LocalDetailTable.Rows[0]["Do_Am_PT"] = 0;
            base.LocalDetailTable.Rows[0]["Do_Con_PT"] = 0;
            if (base.AppInvoiceParameters.AllowDepartmentControl != 1)
            {
                base.LocalMasterRow["Ma_Bp"] = DBNull.Value;
                base.LocalMasterRow["Ten_Bp"] = DBNull.Value;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 1)
            {
                base.LocalMasterRow["Ma_Hd"] = DBNull.Value;
                base.LocalMasterRow["Ten_Hd"] = DBNull.Value;
            }
            base.OnAdd();
        }

        internal override void OnCopy()
        {
            object obj2 = base.LocalMasterRow["So_Ct"];
            base.LocalMasterRow["So_Ct"] = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            base.OnCopy();
        }

        internal override void OnResetControls()
        {
            base.DetailGridBrowser = this.grdDetail;
            int num = 0;
            if (base.AppInvoiceParameters.AllowDepartmentControl != 1)
            {
                num += this.txtMa_Hd.Top - this.txtMa_Bp.Top;
                this.lblMa_Bp.Visible = false;
                this.txtMa_Bp.Visible = false;
                this.txtTen_Bp.Visible = false;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 1)
            {
                num += this.txtDien_Giai.Top - this.txtMa_Hd.Top;
                this.lblMa_Hd.Visible = false;
                this.txtMa_Hd.Visible = false;
                this.txtTen_Hd.Visible = false;
            }
            if (num != 0)
            {
                if (base.AppInvoiceParameters.AllowContractControl == 1)
                {
                    this.lblMa_Hd.Top -= num;
                    this.txtMa_Hd.Top -= num;
                    this.txtTen_Hd.Top -= num;
                }
                this.lblDien_Giai.Top -= num;
                this.txtDien_Giai.Top -= num;
                this.lblDesc_EN.Top -= num;
                this.txtDesc_EN.Top -= num;
                this.grdDetail.Top -= num;
                this.grdDetail.Height += num;
            }
            if (!base.AppInvoiceParameters.BilingualUsed)
            {
                this.lblDesc_EN.Visible = false;
                this.txtDesc_EN.Visible = false;
                this.txtDien_Giai.Width = (this.txtDesc_EN.Left + this.txtDesc_EN.Width) - this.txtDien_Giai.Left;
                this.txtDien_Giai.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            }
            if (base.AppInvoiceParameters.AllowDepartmentControl != 2)
            {
                base.DetailGridBrowser.Columns[5].Visible = false;
            }
            if (base.AppInvoiceParameters.AllowContractControl != 2)
            {
                base.DetailGridBrowser.Columns[6].Visible = false;
            }
            if (!AppInstance.LotNumberCtrl)
            {
                base.DetailGridBrowser.Columns[7].Visible = false;
            }
            if (!AppInstance.DeadLineCtrl)
            {
                base.DetailGridBrowser.Columns[8].Visible = false;
            }
            if (!AppInstance.QualityCtrl)
            {
                base.DetailGridBrowser.Columns[9].Visible = false;
            }
            if (!AppInstance.DampCtrl)
            {
                base.DetailGridBrowser.Columns[10].Visible = false;
            }
            if (!AppInstance.AlcoholCtrl)
            {
                base.DetailGridBrowser.Columns[11].Visible = false;
            }
            if (base.AppInvoiceParameters.FreeFields <= 0)
            {
                num = base.txtMa_Loai1.Top - this.txtGhi_Chu.Top;
                this.lblGhi_Chu.Top += num;
                this.txtGhi_Chu.Top += num;
                this.lblTTien_Nt.Top += num;
                this.txtTTien_Nt.Top += num;
                this.grdDetail.Height += num;
            }
            base.OnResetControls();
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if (((this.txtDien_Giai != null) && (base.AppInvoiceParameters != null)) && base.AppInvoiceParameters.BilingualUsed)
            {
                int num = base.ClientSize.Width - 0xcb;
                this.txtDien_Giai.Width = num / 2;
                this.txtDesc_EN.Left = (this.txtDien_Giai.Left + this.txtDien_Giai.Width) + 0x5c;
                this.txtDesc_EN.Width = num - this.txtDien_Giai.Width;
                this.lblDesc_EN.Left = (this.txtDesc_EN.Left - this.lblDesc_EN.Width) - 6;
            }
        }

        protected override bool OnSave()
        {
            if (base.txtNgay_Ps.Value == DBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày phát sinh!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.txtNgay_Ct.Value == DBNull.Value)
            {
                MessageBox.Show("Chưa nhập ngày chứng từ!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) < AppInstance.OpeningDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.OpeningDateOfSubEnterprice.ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (((DateTime) base.txtNgay_Ct.Value) <= AppInstance.EndingDateOfSubEnterprice)
            {
                MessageBox.Show("Ngày chứng từ phải từ ngày " + AppInstance.EndingDateOfSubEnterprice.AddDays(1.0).ToShortDateString(), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (!base.CheckNewRow)
            {
                int num = this.oMethod.CheckInvoiceStatus(AppInstance.Subsidiary, AppInstance.UserName, base.SavedMasterOrder);
                switch (num)
                {
                    case 9:
                    case 7:
                        break;

                    default:
                        if ((base.AppInvoiceParameters.AllowPostInvoice && base.AppInvoiceParameters.AllowLockInvoice) || ((num != 6) && (num != 5)))
                        {
                            if (num == 8)
                            {
                                base.AppInvoiceParameters.ShowInvoiceUsed(base.SavedMasterOrder, base.AppInvoiceParameters.StatusMessage(num));
                                return false;
                            }
                            goto Label_0178;
                        }
                        break;
                }
                MessageBox.Show(base.AppInvoiceParameters.StatusMessage(num), AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
        Label_0178:
            if (this.oMethod.NumberExisted(AppInstance.Subsidiary, base.CheckNewRow, base.SavedMasterOrder, base.InvoiceCode, base.txtNgay_Ct.Value, base.txtSo_Ct.Value) && (MessageBox.Show("Số chứng từ đã tồn tại. C\x00f3 tiếp tục không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No))
            {
                if (MessageBox.Show("C\x00f3 muốn tự động tạo số chứng từ không?", AppInstance.SoftwareName, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return false;
                }
                object obj2 = base.txtSo_Ct.Value;
                base.txtSo_Ct.Value = this.oMethod.Cong_So_Ct(AppInstance.Subsidiary, base.InvoiceCode, base.LocalMasterRow["Ngay_Ct"], obj2);
            }
            base.DetailGridBrowser.EndEdit();
            base.LocalMasterRow["Ngay_Ps"] = base.txtNgay_Ps.Value;
            base.LocalMasterRow["Ngay_Ct"] = base.txtNgay_Ct.Value;
            base.LocalMasterRow["So_Ct"] = base.txtSo_Ct.Value;
            base.LocalMasterRow["Ma_YC"] = this.txtMa_YC.Value;
            base.LocalMasterRow["Ten_YC"] = this.txtTen_YC.Value;
            base.LocalMasterRow["Ma_NN"] = this.txtMa_NN.Value;
            base.LocalMasterRow["Ten_NN"] = this.txtTen_NN.Value;
            base.LocalMasterRow["Ma_Bp"] = this.txtMa_Bp.Value;
            base.LocalMasterRow["Ten_Bp"] = this.txtTen_Bp.Value;
            base.LocalMasterRow["Ma_Hd"] = this.txtMa_Hd.Value;
            base.LocalMasterRow["Ten_Hd"] = this.txtTen_Hd.Value;
            base.LocalMasterRow["Dien_Giai"] = this.txtDien_Giai.Value;
            base.LocalMasterRow["Desc_EN"] = this.txtDesc_EN.Value;
            base.LocalMasterRow["Ghi_Chu"] = this.txtGhi_Chu.Value;
            base.LocalMasterRow["TTien0"] = this.txtTTien_Nt.Value;
            base.LocalMasterRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            base.LocalMasterRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            base.LocalMasterRow["Ma_Loai3"] = base.txtMa_Loai3.Value;
            bool flag = true;
            if (this.oMethod.Save(base.AppInvoiceParameters.InvoiceHistory, base.CheckNewRow, AppInstance.Subsidiary, AppInstance.UserName, base.LocalMasterRow, base.LocalDetailTable, ref flag))
            {
                return base.OnSave();
            }
            if (!flag)
            {
                MessageBox.Show("Phiếu nhập thành phẩm đã thực hiện qu\x00e1 lệnh sản xuất!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
            return false;
        }

        internal override void OnShow()
        {
            base.OnShow();
            this.txtMa_YC.Value = base.LocalMasterRow["Ma_YC"];
            this.txtTen_YC.Value = base.LocalMasterRow["Ten_YC"];
            this.txtMa_NN.Value = base.LocalMasterRow["Ma_NN"];
            this.txtTen_NN.Value = base.LocalMasterRow["Ten_NN"];
            this.txtMa_Bp.Value = base.LocalMasterRow["Ma_Bp"];
            this.txtTen_Bp.Value = base.LocalMasterRow["Ten_Bp"];
            this.txtMa_Hd.Value = base.LocalMasterRow["Ma_Hd"];
            this.txtTen_Hd.Value = base.LocalMasterRow["Ten_Hd"];
            this.txtDien_Giai.Value = base.LocalMasterRow["Dien_Giai"];
            this.txtDesc_EN.Value = base.LocalMasterRow["Desc_EN"];
            this.txtGhi_Chu.Value = base.LocalMasterRow["Ghi_Chu"];
            this.txtTTien_Nt.Value = base.LocalMasterRow["TTien0"];
        }

        private void SetFunctions()
        {
            ToolStripMenuItem item = new ToolStripMenuItem();
            item.AutoSize = true;
            item.Text = "Chọn lệnh sản xuất";
            item.Click += new EventHandler(this.ChooseCommand);
            base.ToolStripFunctions = new ToolStripItem[] { item };
        }

        private void SetItemRatio()
        {
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            DataRow row2 = AppDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
            if (row2 != null)
            {
                if (row["Dvt"].Equals(row2["Dvt"]))
                {
                    row["He_So9"] = 1;
                }
                else if (row["Dvt"].Equals(row2["Dvt0"]))
                {
                    row["He_So9"] = row2["He_So0"];
                }
                else if (row["Dvt"].Equals(row2["Dvt1"]))
                {
                    row["He_So9"] = row2["He_So1"];
                }
                else if (row["Dvt"].Equals(row2["Dvt2"]))
                {
                    row["He_So9"] = row2["He_So2"];
                }
                row.EndEdit();
                this.Calculate(row, 2);
                this.Sum();
            }
        }

        private void SetItemUnits()
        {
            DataRow row = ((DataRowView) base.DetailGridBrowser.CurrentRow.DataBoundItem).Row;
            DataRow row2 = AppDataAccess.SelectDataRow(false, "DMVT", "Ma_Vt", row["Ma_Vt"].ToString(), null);
            if (row2 != null)
            {
                if (string.IsNullOrEmpty(row2["Dvt0"].ToString()))
                {
                    base.DetailGridBrowser.CurrentCell.ReadOnly = true;
                }
                else
                {
                    string str = (string.IsNullOrEmpty(row2["Dvt"].ToString()) ? "" : row2["Dvt"].ToString()) + (string.IsNullOrEmpty(row2["Dvt0"].ToString()) ? "" : ("," + row2["Dvt0"].ToString())) + (string.IsNullOrEmpty(row2["Dvt1"].ToString()) ? "" : ("," + row2["Dvt1"].ToString())) + (string.IsNullOrEmpty(row2["Dvt2"].ToString()) ? "" : ("," + row2["Dvt2"].ToString())) + (string.IsNullOrEmpty(row2["Dvt3"].ToString()) ? "" : ("," + row2["Dvt3"].ToString()));
                    (base.DetailGridBrowser.CurrentCell as OptionCell).InputMask = str;
                    base.DetailGridBrowser.CurrentCell.ReadOnly = false;
                }
            }
        }

        private bool Sum()
        {
            decimal num = 0M;
            foreach (DataRow row in base.LocalDetailTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    num += (decimal) row["Tien"];
                }
            }
            base.LocalMasterRow["TTien0"] = num;
            this.txtTTien_Nt.Value = num;
            return true;
        }

        private void txtMa_Bp_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Bp.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Bp.OldValue.Equals(row["Ma_Bp"]) || (this.txtMa_Bp.OldValue.ToString() == row["Ma_Bp"].ToString())))
                    {
                        row["Ma_Bp"] = this.txtMa_Bp.Value;
                        row["Ten_Bp"] = this.txtTen_Bp.Value;
                    }
                }
            }
        }

        private void txtMa_Hd_Validated(object sender, EventArgs e)
        {
            if (this.txtMa_Hd.ValueChanged)
            {
                foreach (DataRow row in base.LocalDetailTable.Rows)
                {
                    if ((row.RowState != DataRowState.Deleted) && (this.txtMa_Hd.OldValue.Equals(row["Ma_Hd"]) || (this.txtMa_Hd.OldValue.ToString() == row["Ma_Hd"].ToString())))
                    {
                        row["Ma_Hd"] = this.txtMa_Hd.Value;
                        row["Ten_Hd"] = this.txtTen_Hd.Value;
                    }
                }
            }
        }
    }
}

